? 000
? 000 To be contributed.patch
? 480646.patch
Index: invite.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/invite/invite.module,v
retrieving revision 1.25.2.6
diff -u -p -r1.25.2.6 invite.module
--- invite.module	27 Apr 2009 17:24:44 -0000	1.25.2.6
+++ invite.module	12 Jun 2009 05:39:36 -0000
@@ -423,7 +423,7 @@ function invite_user($op, &$edit, &$acco
         }
       }
       if ($invite) {
-        _invite_accept($invite, $account);
+        _invite_accept($invite, $account, $edit);
 
         // Flag the inviting user, this triggers status notifications and
         // saves us some queries otherwise.
@@ -449,7 +449,7 @@ function invite_user($op, &$edit, &$acco
  * @param $account
  *   The user object of the invitee.
  */
-function _invite_accept($invite, $account) {
+function _invite_accept($invite, $account, &$edit) {
   // Update the invitation record.
   db_query("UPDATE {invite} SET email = '%s', invitee = %d, joined = %d WHERE reg_code = '%s'", $account->mail, $account->uid, time(), $invite->reg_code);
   // Delete all invites to these e-mail addresses, except this one.
@@ -458,7 +458,7 @@ function _invite_accept($invite, $accoun
   // notification queue.
   db_query("INSERT INTO {invite_notifications} (uid, invitee) SELECT uid, %d from {invite} WHERE (email = '%s' OR email = '%s') AND canceled = 0", $account->uid, $invite->email, $account->mail);
   // Escalate the invitee's role.
-  _invite_escalate_role($account);
+  _invite_escalate_role($account, $edit);
   // Unblock user account.
   db_query("UPDATE {users} SET status = 1 WHERE uid = %d", $account->uid);
 }
@@ -469,7 +469,7 @@ function _invite_accept($invite, $accoun
  * @param $account
  *   The user object of the invitee.
  */
-function _invite_escalate_role($account) {
+function _invite_escalate_role($account, &$edit) {
   // Default target role.
   $roles = array('default');
 
@@ -489,15 +489,12 @@ function _invite_escalate_role($account)
     }
   }
 
-  // Notify other modules of changed user.
-  $edit = array('roles' => $targets);
-  user_module_invoke('update', $edit, $account);
-
-  // Save new user role(s).
-  foreach ($targets as $target) {
-    db_query("DELETE FROM {users_roles} WHERE uid = %d AND rid = %d", $account->uid, $target);
-    db_query("INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)", $account->uid, $target);
+  // Let user_save() save the new user role(s).
+  if (!is_array($edit['roles'])) {
+    $edit['roles'] = array();
   }
+  $edit['roles'] += $targets;
+  $account->roles += $targets;
 
   // Notify other modules of role escalation.
   $args = array('invitee' => $account, 'inviter' => $inviter, 'roles' => $targets);
@@ -623,7 +620,7 @@ function invite_get_remaining_invites($a
   }
 
   // Check user property for remaining invites.
-  $data = unserialize($account->data);
+  // $data = unserialize($account->data);
   if (isset($data['invites'])) {
     $remaining = $data['invites'];
   }
@@ -632,7 +629,7 @@ function invite_get_remaining_invites($a
 
     if ($remaining > 0) {
       // Legacy support.
-      $sent = db_result(db_query("SELECT COUNT(*) FROM {invite} WHERE uid = %d", $account->uid));
+      $sent = db_result(db_query("SELECT COUNT(*) FROM {invite} WHERE uid = %d AND canceled < 1", $account->uid));
       $remaining = max($remaining - $sent, 0);
       if ($sent > 0) {
         // Update user property for faster lookup next time.
Index: invite_admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/invite/invite_admin.inc,v
retrieving revision 1.3.2.2
diff -u -p -r1.3.2.2 invite_admin.inc
--- invite_admin.inc	19 Apr 2009 21:26:01 -0000	1.3.2.2
+++ invite_admin.inc	12 Jun 2009 05:39:36 -0000
@@ -67,12 +67,12 @@ function invite_settings() {
       '#required' => TRUE,
     );
     $form['role'][$role_no_space]['invite_maxnum_'. $role_no_space] = array(
-      '#type' => 'select',
+      '#type' => 'textfield',
       '#title' => t('Invitation limit'),
       '#default_value' => variable_get('invite_maxnum_'. $role_no_space, INVITE_UNLIMITED),
-      '#options' => array(5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100, 500 => 500, 1000 => 1000, INVITE_UNLIMITED => t('unlimited')),
-      '#description' => t('Allows to limit the total number of invitations members of %role can send.', array('%role' => $role)),
-      '#multiple' => FALSE,
+      '#size' => 10,
+      '#maxlength' => 10,
+      '#description' => t('Allows to limit the total number of invitations members of %role can send. Enter <em>%unlimited</em> for unlimited number of invitations.', array('%role' => $role, '%unlimited' => INVITE_UNLIMITED)),
       '#required' => TRUE,
     );
   }
